package cn.qingyun.gis.modules.express.controller;

import cn.qingyun.gis.common.Result;
import cn.qingyun.gis.modules.express.entity.HwQuery;
import cn.qingyun.gis.modules.express.request.HwGetGridIdRequest;
import cn.qingyun.gis.modules.express.request.HwGetTokenRequest;
import cn.qingyun.gis.modules.express.service.IHwRestApiService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
/**
 * 调用华为外部接口
 * */

@RestController
@RequestMapping(value = "/hw")
public class HwCallController {

    //  ------------------华为融网格封装接口---------------------
    @Resource
    private IHwRestApiService iHwRestApiService;

    @ApiOperation(value = "华为网格-边界查询")
    @PostMapping(value = "/grid/gridBoundaryQuery")
    public Result<?> gridBoundaryQuery(@RequestBody HwQuery hwQuery) {
        return Result.okData(iHwRestApiService.gridBoundaryQuery(hwQuery));
    }

    @ApiOperation(value = "华为网格-资源查询")
    @PostMapping(value = "/grid/gridResourceQuery")
    public Result<?> gridResourceQuery(@RequestBody HwQuery hwQuery) {
        return Result.okData(iHwRestApiService.gridResourceQuery(hwQuery));
    }

    @ApiOperation(value = "华为网格-根据工号进行区域权限查询")
    @PostMapping(value = "/grid/getGridByAccount")
    public Result<?> getGridByAccountTest(@RequestBody HwGetGridIdRequest hwQuery) {
        return Result.okData(iHwRestApiService.getGridByAccountTest(hwQuery));
    }


    //  -------------------能开服务-(目前只有生产地址)---------------------
    // 注意：在云桌面调用封装接口不能直接使用生产环境域名，使用生产地址 134.80.173.9

    @ApiOperation(value = "华为-获取token")
    @PostMapping(value = "/pro/getToken")
    public Result<?> getToken(@RequestBody HwGetTokenRequest request) {
        return Result.okData(iHwRestApiService.getToken(request));
    }

    @ApiOperation(value = "华为能开-根据工号与token进行区域权限查询")
    @PostMapping(value = "/pro/getGridByAccount")
    public Result<?> getGridByAccount(@RequestBody HwGetGridIdRequest request) {
        return Result.okData(iHwRestApiService.getGridByAccount(request));
    }
}
